<template>
	 <ul>
        <li v-for="(item,index) in list" :key="index" v-if="item.lineType!=3">
        	<router-link :to="'/transport/'+item.lineId">
        		<div >
		            <div class="road-title">
		                <span>{{item.fromCity}} - {{item.toCity}}</span>
		                <span>{{item.transTypeName}}</span>
		            </div>
		            <p><i>￥{{item.transPriceDisplay}}</i><span class="wy-col-33">起</span></p>
		            <div class="road-money">
		                <span v-if="item.transType == '32'">最低一票价:<i>{{item.transPriceDisplay}}</i>元</span>
		                <span v-if="item.lineType == '2'">最低一票价:<i>{{item.transPriceDisplay}}</i>元</span>
		                <button v-if="item.validDay">时效:{{item.validDay}}天</button>
		                <button v-if="!item.validDay">长期有效</button>
		            </div>
		        </div>
	        </router-link>
        </li>
        <!-- 航空 -->
 		<li v-for="(item,index) in list" :key="index"  v-if="item.lineType ==3&&index<=1" class="air-content">
        	<router-link :to="'/transport/'+item.lineId">
        		<!-- 日期 -->
        		<div class="air-left-time">
		            <span>{{dateTypeTime(item.fromTime,'MM:DD') }}</span>
		            <span>{{dateTypeTime(item.fromTime,'周')}}</span>
		        </div>
		        <div class="air-right-detail">
		        	<div class="air-surplus">
		        		<span>剩余仓位</span>
		        		<a-progress strokeLinecap="square" :format="percent => `${percent}%`" :percent="chaNum(item.airSpaceSurplus,item.airSpaceTotal)" /><span>可用</span>
		        	</div>
		            <div class="air-company-road">
			        	<div class="air-fly">
			        	 	  <img src="./../.././../static/img/index/airIcon.png" alt="" />
			        	</div>
			        	<!-- 航空信息 -->
			        	<div class="air-comany-name">
			        		<span>{{item.transTypeName}}</span>
			        		<span>{{item.airModelValue}}</span>
			        	</div>
			        	<!-- 线路中转 -->
			        	<div class="air-road-change">
			        		<!-- 出发机场 -->
			        		<div class="air-start-place">
			        		 	<span>{{dateTypeTime(item.fromTime,'HH:MM') }}</span>
			        		 	<span>{{item.fromAirPortName}}</span>
			        		</div>
			        		<div class="air-line">
			        			<!-- <div class="air-transfer">
			        				中转(杭州)
			        			</div> -->
			        			<div class="air-line-pic">
			        				 <img src="./../../.././static/img/index/roadLine.png" alt="" />
			        			</div>
			        			<div class="air-arrive-time">
			        				抵达时间：{{dateTimeChang(item.fromTime,item.toTime)}}
			        			</div>
			        		</div>
			        		<!-- 到达机场 -->
			        		<div class="air-end-place">
				        		<span>{{dateTypeTime(item.toTime,'HH:MM') }}</span>
				        		<span>{{item.toAirPortName}}</span>
				        	</div>
			        	</div>
			        	<!-- 机票价格 -->
			        	<div class="air-price">￥<i>{{item.transPriceDisplay}}</i>元</div>

			        </div>
		        </div>
	        </router-link>
        </li>
    </ul>
</template>
<script>
	export default{
		props: {
	        list: {
	        	default: () => []
	        }
	    },
	    methods: {
			// 时分 
			dateTypeTime(time,type) {
				if (time){
			      time = time.replace(/-/g,'/');
				  if(type == 'HH:MM'){
				    let h = new Date(time).getHours()
				    let f = new Date(time).getMinutes()
				    return (h<9?'0':'')+h+':'+ (f<9?'0':'')+f
				  }
				  if(type == 'MM:DD'){
				    let m = new Date(time).getMonth()+1
				    let d = new Date(time).getDate()
				    return (m<9?'0':'')+m+'-'+ (d<9?'0':'')+d
				  }
				  if(type == '周'){
				    let day = new Date(time).getDay(),text = "";
				    switch (day) {
				      case 0: text = "星期日"; break;
				      case 1: text = "星期一"; break;
				      case 2: text = "星期二"; break;
				      case 3: text = "星期三"; break;
				      case 4: text = "星期四"; break;
				      case 5: text = "星期五"; break;
				      case 6: text = "星期六"; break;
				    }
				    return text
				  }
				}
				return ''
			},
		    // 百分比
		    chaNum (min,max) {
		        let num = (min/max)*100;
		        if (num>100) num = 100
		        return parseInt(num) || 0
		    },
		    // 两时间差 时分
		    dateTimeChang (min,max){
		        if (min && max){
		          min = min.replace(/-/g,'/');
        		  max = max.replace(/-/g,'/');
		          let time = new Date(max).getTime()-new Date(min).getTime()
		          let h = parseInt(time/3600000)
		          let f = parseInt((time%3600000)/1000/60)
		          return (h<9&h>0?'0':'')+h+'小时'+(f<9&f>0?'0':'')+f+'分'
		        }
		        return ''
		    },
	    }
	}
</script>
<style lang="scss">
</style>